package com.weipai.springboot.module.mapper;

import com.weipai.springboot.model.GiftCertificate;
import com.weipai.springboot.model.SpecialOffer;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;

import java.util.List;
import java.util.Map;

public interface GiftCertificateMapper{

    int deleteByPrimaryKey(String giftCertificateId);

    int insert(GiftCertificate record);

    int insertSelective(GiftCertificate record);

    GiftCertificate selectByPrimaryKey(String giftCertificateId);

    int updateByPrimaryKeySelective(GiftCertificate record);

    int updateByPrimaryKey(GiftCertificate record);

    //查询礼券详情
    GiftCertificate getGiftCertificateById(String id);

    //删除
    @Update("update c_gift_certificate set gift_certificate_del=-1, del_time=date_format(now(), '%Y-%m-%d %H:%i:%s') " +
                   "where gift_certificate_id=#{id}")
    int updateDel(String id);

    //更改礼券的状态--启用/禁用
    @Update("update c_gift_certificate set gift_certificate_status=#{status}, update_time=date_format(now(), '%Y-%m-%d %H:%i:%s') " +
            "where gift_certificate_id=#{id}")
    int updateStatus(@Param("id") String id, @Param("status") Integer status);

    //查询总数量
    Integer selectAllByPageAmount();

    //分页查询
    List<Map<String, Object>> selectAllByPage(@Param("start") Integer start, @Param("end") Integer end);

    //用户的优惠券
    List<Map<String,Object>> getCustomerGift(@Param("customerId") String customerId, @Param("status") Integer status,
                                             @Param("start") Integer start, @Param("size") Integer size);

    //用户的优惠券的总数量
    Integer getCustomerGiftAmount(@Param("customerId") String customerId, @Param("status") Integer status);

    //批量删除
    int batchDeleteById(String[] id);

    List<GiftCertificate> getAll();

    List<Map<String,Object>> selectAllByPage22(@Param("start") Integer start, @Param("end") Integer end);

    Integer selectAllByPageAmount22();
}